<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php $this->load->view('admin/header.html')?>
<?php echo !empty($init) && $init==1? '<script type="text/javascript">$(function(){parent.manage_menu();})</script>':"" ?>
<script type="text/javascript">
    function Success(data) {
        $.Success(data);
        setTimeout(function () { window.location.href = window.location.href; }, 3000);
    }
    function EditUse(mid, state) {
        $.post('/admin/menu/setuse', { 'mid': mid, 'state': state }, function (data) {
            var jsonData = $.parseJSON(data);

            if (jsonData.Statu == 'ok') {
                alert(jsonData.Msg);
                location.href = jsonData.BackUrl;
            }
            else {
                alert(jsonData.Msg);
            }
        });
    }

    function Del_Top(menuid) {
        url = "/admin/menu/del_top_menu/" + menuid;
        layer.confirm("删除此栏目，其所有子集栏目都会删除，确定删除？", function () {
            $.post(url, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }
</script>
<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心
        <?php foreach($crumbs_items as $crumbs_item):?>
        <b>></b><a href="<?php echo $crumbs_item[0]?>"><?php echo $crumbs_item[1]?></a>
        <?php endforeach;?>
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>
            <a href="<?php echo site_url('admin/menu/addmenu')?>" class="actionBtn">添加栏目</a>栏目列表
        </h3>
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th width="30" align="center">编号</th>
                <th align="left">栏目名称</th>
                <th align="center">权重</th>
                <th align="center">操作</th>
            </tr>
            <?php foreach($top_level_menu as $menu_top_item):?>
            <tr>
                <td align="center"><?php echo $menu_top_item->menuid;?></td>
                <td><?php echo $menu_top_item->title;?></td>
                <td align="center"><?php echo $menu_top_item->weight;?></td>
                <td align="center">
                    <a href="<?php echo site_url('admin/menu/child_menu/'.$menu_top_item->menuid)?>">子集管理</a>|
                    <a href="javascript:Del_Top(<?php echo $menu_top_item->menuid?>)">删除</a>
                </td>
            </tr>
            <?php endforeach; ?>
        </table>
        <div class='page'>
        </div>
    </div>
</div>